import express from 'express'
import path from 'path'
import {readJson} from '../util/PromiseJson.js'
import __dirname from '../util/dirname.js'

const router = express.Router()

router.get('/getAllMapTile',async (req,res)=>{
    console.log(`请求进来了，${req.headers['content-type']}`)
    const baseurl = 'http://localhost:9600'
    const data = await readJson(src('mapTileDatas.json')) 
    data.forEach(tile => {
            tile.src = baseurl + tile.src
    });
    res.send(data)
})

function src(dir){
    return path.join(__dirname ,'../data',dir )
}


export default router